package cn.laixueit.mapper;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

@Repository

public class StudentMapper {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    public void findAll(){
        jdbcTemplate.execute("select count(1) from student");
        jdbcTemplate.execute("select * from student");
    }



    @Transactional(rollbackFor = RuntimeException.class)
    public void save(){
        jdbcTemplate.execute("insert into student(name) values('李四')");
        int i = 1/0;
        jdbcTemplate.execute("insert into student(name) values('王五')");
    }

    public void save2(){
        jdbcTemplate.execute("insert into student(name1) values('李四')");
    }
}
